package com.sanjiahantang.ythshopping.presenter;


import android.content.Context;

import com.sanjiahantang.ythshopping.config.ConfigValue;
import com.sanjiahantang.ythshopping.http.BaseDelegate;
import com.sanjiahantang.ythshopping.http.ExceptionHelper;
import com.sanjiahantang.ythshopping.http.OkHttpClientManager;
import com.sanjiahantang.ythshopping.model.LeaveMsgModle;
import com.sanjiahantang.ythshopping.utils.Utils;
import com.sanjiahantang.ythshopping.views.LeaveMsgView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

public class MyLeavelistPresenter extends BasePresenter {

    LeaveMsgView leavemsgview;
    Context context;
    public MyLeavelistPresenter (Context context,LeaveMsgView leavemsgview)
    {
        this.leavemsgview=leavemsgview;
        this.context=context;
    }

    public void LoadLeaveMsg(int page)
    {
        initLoadDialog(context);
        mLoadingDialog.show();
        Map<String ,String> params=new HashMap<>();
        params.put("page",page+"");
        params.put("key",ConfigValue.DATA_KEY);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "msg/msgList", params, new BaseDelegate.ResultCallback<LeaveMsgModle>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                dismiss();
                Utils.showToast(context, ExceptionHelper.getMessage(e, context));
            }

            @Override
            public void onResponse(LeaveMsgModle response, Object tag) {
                dismiss();
                leavemsgview.getLeavelist(response);
            }
        });
    }


}